<?php
/**
 * Project: AIGC
 * Author: moufer <moufer@163.com>
 * Date: 2024/7/18 22:26
 */

namespace module\user\front\table;

use mof\enum\EnableEnum;
use mof\enum\YesNoEnum;
use mof\front\Table;
use mof\utils\DictArray;
use mof\utils\ElementData;

class UserTable extends Table
{
    protected string $serverBaseUrl  = '/{module}/admin/{table}';
    protected array  $toolbarButtons = ['refresh', 'delete', 'status', 'search'];

    protected function columnId(): array
    {
        return [
            "prop"   => 'id',
            "label"  => 'ID',
            "search" => true,
        ];
    }

    protected function columnAvatar(): array
    {
        return [
            "prop"  => 'avatar',
            "label" => '头像',
            "type"  => 'avatar',
        ];
    }

    protected function columnUsername(): array
    {
        return [
            "prop"  => 'username',
            "label" => '用户名',
            "width" => "*"
        ];
    }

    protected function columnMobile(): array
    {
        return [
            "prop"   => 'mobile',
            "label"  => '手机号',
            "search" => true,
            "width"  => "*"
        ];
    }

    protected function columnNickname(): array
    {
        return [
            "prop"  => 'nickname',
            "label" => '昵称',
            "width" => "*"
        ];
    }

    protected function columnScore(): array
    {
        return [
            "prop"  => 'score',
            "label" => '积分',
        ];
    }

    protected function columnVip(): array
    {
        return [
            "prop"    => 'vip',
            "label"   => 'VIP',
            "type"    => "select",
            "search"  => true,
            "options" => YesNoEnum::toDict()->toElementData()->toSelectOptions(),
        ];
    }

    protected function columnStatus(): array
    {
        return [
            "prop"    => 'status',
            "label"   => '状态',
            "type"    => "select",
            "options" => EnableEnum::toDict()->toElementData()->toSelectOptions(),
            "search"  => true,
        ];
    }

    protected function columnLoginAt(): array
    {
        return [
            "prop"   => 'login_at',
            "label"  => '登录时间',
            "type"   => "datetime",
            "search" => [
                'type' => 'datetimerange',
            ],
        ];
    }

    protected function columnCreateAt(): array
    {
        return [
            "prop"   => 'create_at',
            "label"  => '新增时间',
            "type"   => "datetime",
            "search" => [
                'type' => 'datetimerange',
            ],
        ];
    }

}